package com.mybatis.example.controller;


import com.mybatis.example.entity.User;
import com.mybatis.example.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author sam
 * @since 2020-09-22
 */
@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    IUserService userService;

    @GetMapping("/hello")
    public Object test(@RequestParam("name") String name){
//        try {
            List<User> list = userService.findSA(name);
//            if (list.size() > 0) {
//                System.out.print(list);
                return list;
//            }
//            return "no data";
//        } catch (Exception e){
//            return "error";
//        }
    }
}

